function a(a, t, o) {
    return t in a ? Object.defineProperty(a, t, {
        value: o,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : a[t] = o, a;
}

var t = require("../../utils/api.js"), o = getApp();

Page({
    data: {
        nav: [ {
            name: "佣金流水",
            color: "#ff5555",
            on: !0,
            type: "commission"
        }, {
            name: "提现流水",
            color: "#ff5555",
            on: !1,
            type: "cash"
        } ],
        showMore: !1,
        noMore: !1,
        showLoding: !1
    },
    onLoad: function(e) {
        for (var n = this, s = 0; s < n.data.nav.length; s++) {
            var i = "nav[" + s + "].on";
            n.data.nav[s].type == e.type ? n.setData(a({}, i, !0)) : n.setData(a({}, i, !1));
        }
        "commission" == e.type && t.headCommissionList({
            openid: o.globalData.openid
        }).then(function(a) {
            if (console.log(a), 0 == a.errno) {
                if (a.data.data.length < 10) var t = !0;
                n.setData({
                    info: a.data.data,
                    page: 2,
                    type: e.type,
                    noMore: t
                });
            } else n.setData({
                info: [],
                type: e.type
            });
            n.setData({
                showLoding: !0
            });
        }), "cash" == e.type && t.headGetCashList({
            openid: o.globalData.openid
        }).then(function(a) {
            if (console.log(a), 0 == a.errno) {
                if (a.data.data.length < 10) var t = !0;
                n.setData({
                    info: a.data.data,
                    page: 2,
                    type: e.type,
                    noMore: t
                });
            } else n.setData({
                info: [],
                type: e.type
            });
            n.setData({
                showLoding: !0
            });
        });
    },
    changenav: function(e) {
        console.log(e);
        var n = this;
        n.setData({
            info: "",
            showLoding: !1
        });
        for (var s = e.currentTarget.dataset.type, i = 0; i < n.data.nav.length; i++) {
            var r = "nav[" + i + "].on";
            if (n.data.nav[i].type == s) {
                var d;
                n.setData((d = {}, a(d, r, !0), a(d, "type", s), a(d, "noMore", !1), d));
            } else n.setData(a({}, r, !1));
        }
        "commission" == s && t.headCommissionList({
            openid: o.globalData.openid
        }).then(function(a) {
            if (console.log(a), 0 == a.errno) {
                if (a.data.data.length < 10) var t = !0;
                n.setData({
                    info: a.data.data,
                    page: 2,
                    noMore: t
                });
            } else n.setData({
                info: []
            });
            n.setData({
                showLoding: !0
            });
        }), "cash" == s && t.headGetCashList({
            openid: o.globalData.openid
        }).then(function(a) {
            if (console.log(a), 0 == a.errno) {
                if (a.data.data.length < 10) var t = !0;
                n.setData({
                    info: a.data.data,
                    page: 2,
                    noMore: t
                });
            } else n.setData({
                info: []
            });
            n.setData({
                showLoding: !0
            });
        });
    },
    onReachBottom: function() {
        var a = this;
        if (console.log(1), "commission" == a.data.type) {
            if (a.data.noMore) return !1;
            a.setData({
                showMore: !0
            });
            e = a.data.info;
            t.headCommissionList({
                openid: o.globalData.openid,
                page: a.data.page
            }).then(function(t) {
                console.log(t), 0 == t.errno ? (t.data.data.length < 10 ? a.setData({
                    noMore: !0,
                    showMore: !1
                }) : a.setData({
                    noMore: !1,
                    showMore: !1
                }), console.log(e), a.setData({
                    info: e.concat(t.data.data),
                    page: parseInt(a.data.page) + 1,
                    type: "commission"
                }), console.log(a.data.info)) : a.setData({
                    type: "commission",
                    showMore: !1,
                    noMore: !0
                });
            });
        }
        if ("cash" == a.data.type) {
            if (a.data.noMore) return !1;
            a.setData({
                showMore: !0
            });
            var e = a.data.info;
            t.headGetCashList({
                openid: o.globalData.openid,
                page: a.data.page
            }).then(function(t) {
                console.log(t), 0 == t.errno ? (t.data.data.length < 10 ? a.setData({
                    noMore: !0,
                    showMore: !1
                }) : a.setData({
                    noMore: !1,
                    showMore: !1
                }), console.log(e), a.setData({
                    info: e.concat(t.data.data),
                    page: parseInt(a.data.page) + 1,
                    type: "cash"
                })) : a.setData({
                    type: "cash",
                    showMore: !1,
                    noMore: !0
                });
            });
        }
    }
});